package com.onemore.keyword.cpulock;

import com.onemore.keyword.utils.LogUtil;

import android.content.Context;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;

public class AlertWakeLock
{
    private static final String TAG = AlertWakeLock.class.getSimpleName();
    private static WakeLock sCpuWakeLock = null;
    

    public static void acquireCpuWakeLock(Context context) {
        
        if (sCpuWakeLock != null) {
            return ;
        }
        LogUtil.Log(TAG,"Acquiring cpu wake lock");
        PowerManager pm =
                (PowerManager) context.getSystemService(Context.POWER_SERVICE);
 
        sCpuWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "wakelock");
        sCpuWakeLock.acquire();
    }
 
    public static void eleaseCpuLock() {     
        
        if (sCpuWakeLock != null) {
            LogUtil.Log(TAG,"Releasing cpu wake lock");
            sCpuWakeLock.release();
            sCpuWakeLock = null;
        }
    }

}
